//
//  SelectNumPerson.m
//  xjairOA
//
//  Created by apple on 16-1-28.
//  Copyright (c) 2016年 net. All rights reserved.
//

#import "SelectNumPerson.h"

@implementation SelectNumPerson

NSArray * number;

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.picker.dataSource = self;
    self.picker.delegate = self;
    number = [NSArray arrayWithObjects:@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12",@"13",@"14",nil];
    UIBarButtonItem * rightButton = [[UIBarButtonItem alloc] initWithTitle:@"完成" style:UIBarButtonSystemItemCancel target:self action:@selector(finish)];
    [self.navigationItem setRightBarButtonItem:rightButton];
}

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 1;
}

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    
    return number.count;
}

- (NSString*)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    return [number objectAtIndex:row];
}

- (void)finish
{
    NSInteger row = [self.picker selectedRowInComponent:0];
     UILabel * label3 = (UILabel*)[((UIViewController*)[self.navigationController.viewControllers objectAtIndex:2]).view viewWithTag:3];
    label3.text = [number objectAtIndex:row];
     [self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:2] animated:YES];
}

@end
